
package com.viweb.storemanager.core;

import javax.swing.JLabel;

public class LabelText extends JLabel {

    private String baseText;
    private String value;

    /**
     * Creates a new instance of LabelText.
     */
    public LabelText() {
        super();
    }

    /**
     * Creates a new instance of  LabelText.
     * @param label the text will display.
     */
    public LabelText(String label) {
        super(label);
        this.baseText = label;
    }

    /**
     * Creates a new instance of LabelText.
     * @param label the text will be displayed.
     * @param value the value will be displayed.
     * 
     * Display structure: text: value
     */
    public LabelText(String label, String value) {
        super(label);
        this.baseText = label;
        this.setValue(value);
    }

    /**
     * To set the valud for LabelText object.
     * @param value the value will be displayed.
     */
    public void setValue(String value) {
        this.value = value;
        if (this.baseText == null) {
            this.baseText = this.getText();
        }
        if (this.value != null) {
            this.setText(this.baseText + " " + value);
        } else {
            this.setText(this.baseText);
        }
    }

    /**
     * To get the value.
     * @return a string.
     */
    public String getValue() {
        return this.value;
    }
}
